import os
import platform
import sys

import torch
from icecream import ic

# 添加当前目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
print("sys.path:", sys.path)
print(sys.version)

print(platform.architecture(), sys.version)
# print(torch.__version__)

import dose_torch

# ic(torch.__dict__)

# ic(torch._C)
# # ic(dir(torch._C))
# ic(torch._C.__dict__)


# ic(dose_torch.__file__)
# ic(dir(dose_torch))


# ic(dir(torch.ops))

# ic(dir(torch.ops.dose_torch))
# ic(torch.ops.dose_torch.__dict__)


# ic(dir(torch.ops.dose_torch.accumulate))
# ic(dir(torch.ops.dose_torch.accumulate.overloads))
# ic(dir(torch.ops.dose_torch.accumulate.default))
# ic(dir(torch.ops))
# ic(torch.ops.__dict__)


## 列出所有已注册的自定义算子（包括你的 dose_torch）
# print('torch dispatch key:\n', torch._C._dispatch_get_registrations_for_dispatch_key(""))
# ic(torch._C._dispatch_get_registrations_for_dispatch_key(""))
# ic(torch._C._dispatch_get_all_op_names())

##000000000000000000000000000000000000000000000000000000000000000000 验证 operator 是否注册成功
## 以 accumulate 为例
ic(torch.ops.dose_torch.accumulate)
ic(dir(torch.ops.dose_torch.accumulate))

ic(torch.ops.dose_torch.accumulate.overloads)
## default 是默认的重载标签
ic(torch.ops.dose_torch.accumulate.default)
ic(dir(torch.ops.dose_torch.accumulate.default))
